
const routes = {
    path: '/',
    children: [
      {
        path: 'home',
        children: [
          {
            path: 'news'
          },
          {
            path: 'events'
          }
        ]
      },
      {
        path: 'about',
        children: [
          {
            path: 'team'
          },
          {
            path: 'contact'
          }
        ]
      }
    ]
  };
   
  function traverseRoutes(routes, callback) {
    // 对每个路由执行callback函数
    callback(routes);
   
    // 递归遍历子路由
    if (routes.children) {
      routes.children.forEach(childRoute => {
        traverseRoutes(childRoute, callback);
      });
    }
  }
   
  // 使用traverseRoutes函数遍历所有路由
  traverseRoutes(routes, route => {
    console.log(route);
  });